import React from 'react';

import { Store } from 'redux';

import { Provider } from 'react-redux';

import { persistStore } from 'redux-persist';

import { PersistGate } from 'redux-persist/integration/react';

export default (store: Store) => (
  (Component: React.ComponentType) => (
    (props: any) => (
      <Provider store={store}>
        <PersistGate
          persistor={persistStore(store)}
          children={<Component {...props} />}
        />
      </Provider>
    )
  )
)
